<?php

class HtmlForeignKeyRenderer {
	
	function Render( &$oConfiguration, &$oForeignKey ) {
		
		if ( !$oConfiguration->GetProperty( 'ShowForeignKeys' ) ) {
			return '';
		}

		if ( !$oConfiguration->GetProperty( 'ShowForeignKeysToFilteredTables' ) && $oForeignKey->ReferencesAFilteredTable() ) {
			return '';	
		}
		
		$sTitle  = HtmlTag::H( 2, $oForeignKey->GetName() );
		
		$sText  = 'From '. HtmlTableRenderer::MakeTableNameLink( $oConfiguration, $oForeignKey->GetFromTableName(), $oForeignKey->IsFromAFilteredTable() );
		if ( ! $oForeignKey->IsFromAFilteredTable() ) {
			$sText .= ' (' . implode( ', ', $oForeignKey->GetColumnNames() ) . ') ';
		}
		
		$sText .= ' to ' . HtmlTableRenderer::MakeTableNameLink( $oConfiguration, $oForeignKey->GetToTableName(), $oForeignKey->IsToAFilteredTable() );

		$sText = HtmlTag::P( $sText );

		$sText = HtmlTag::Div( $sTitle . $sText, 'ForeignKey', $oForeignKey->GetName() );
		
		return $sText;
	}
}
require_once( 'HtmlTag.php' );
?>
